home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / programming / oracle7 7.2 / INSTALL / MAKEDIR.VRF < prev    next >
Encoding:
Text File  |  1995-09-25  |  17.5 KB  |  509 lines

  1. /* Copyright (c) Oracle Corporation 1993.  All Rights Reserved */
  2.  
  3. /*****************************************************************************
  4.   NAME
  5.     makedir.vrf - V3 common checks for valid path name.
  6.  
  7.   DESCRIPTION
  8.     This script requests an absolute directory name until a valid path is
  9.     found.  This directory is created if it does not already exist.  NFS 
  10.     paths are not checked for legal names.  HPFS paths are checked for
  11.     legal HPFS names.  All other paths are checked for legal FAT names.
  12.  
  13.     IN Variables:
  14.       string makedir_default_dir
  15.       string makedir_select_dir_prompt
  16.       string makedir_select_dir_content          (dos/os2 only)
  17.       string makedir_select_dir_help             (dos/os2 only)
  18.         Used in a text dialog to request a directory name.
  19.     If Windows, choose directory dialog is used instead 
  20.     (content & help will not be available).
  21.  
  22.       boolean makedir_root_allowed
  23.         Set to true if '%drive%:\' is considered valid.
  24.  
  25.       boolean makedir_skip_pass
  26.         Set to true means user has already entered a path to check, using
  27.         multiple_text_dialog in calling script, for example.  If unbound,
  28.         default to false.
  29.  
  30.       string makedir_root_message
  31.       string makedir_root_content
  32.       string makedir_root_help
  33.         Used in information dialog if makedir_root_allowed = false and 
  34.     a root path was entered.  The variable %makedir_path_to_check%
  35.     can referred to in these 3 strings to reference the root path
  36.     that was entered.
  37.  
  38.       string list makedir_bad_dir_list
  39.       string list makedir_bad_dir_message_list
  40.       string list makedir_bad_dir_content_list
  41.       string list makedir_bad_dir_help_list
  42.         List of known bad directories and their associated messages.
  43.     These will be checked for and message will be displayed.  Can
  44.     be left unbound (all 4 must be unbound) if empty.  If content
  45.     string is "", then no help is displayed with message.
  46.  
  47.       string list makedir_bad_tree_list
  48.       string list makedir_bad_tree_message_list
  49.       string list makedir_bad_tree_content_list
  50.       string list makedir_bad_tree_help_list
  51.         List of known bad directory trees and their associated messages.
  52.     These will be checked for and message will be displayed.  Can
  53.     be left unbound (all 4 must be unbound) if empty.  If content
  54.     string is "", then no help is displayed with message.
  55.  
  56.      All of the above strings are instantiated immediately before usage.
  57.     
  58.     RETURNS: string
  59.       The valid directory that was specified.  This directory is
  60.       guaranteed to exist.
  61.     
  62.     NOTE:
  63.      This script uses only variables with prefix 'makedir_'.
  64.      This script requires Installer 3.0.10.1.1 or later.
  65.      This script is shared by OS/2, DOS, and Windows.
  66.  
  67.   MODIFIED   MM/DD/YY REASON
  68.   sagarwal   09/13/95 Modified check for bad tree structures
  69.   zzerhoun   03/14/95 In Shared mode, make sure Path is on Network
  70.   zzerhoun   02/06/95 Added makedir_bad_tree_* for directory structures
  71.   zzerhoun   01/03/95 Fixed FAT Path too long bug
  72.   zzerhoun   12/15/94 Changed to allow to set path_to_check in calling script
  73.   zzerhoun   11/08/94 Made '-' and '&' valid characters
  74.   ming       01/13/94 Changed to allow to run under DOS and OS/2.
  75.   ming       01/12/94 Added 'stringsonly to explode calls.
  76.   ming       12/30/93 Created.
  77. *****************************************************************************/
  78.  
  79. {
  80.   { makedir_bad_dir_list = makedir_bad_dir_list; }
  81.   [ 'unbound_variable: 
  82.    { 
  83.      makedir_bad_dir_list = list(); 
  84.      makedir_bad_dir_message_list = list(); 
  85.      makedir_bad_dir_content_list = list();
  86.      makedir_bad_dir_help_list = list();
  87.    } ]
  88.  
  89.   { makedir_bad_tree_list = makedir_bad_tree_list; }
  90.   [ 'unbound_variable: 
  91.    { 
  92.      makedir_bad_tree_list = list(); 
  93.      makedir_bad_tree_message_list = list(); 
  94.      makedir_bad_tree_content_list = list();
  95.      makedir_bad_tree_help_list = list();
  96.    } ]
  97.  
  98.   makedir_old_current_directory = current_directory(); /* need to restore this later */
  99.   makedir_bad_names = list("kbd$","prn","nul","com1","com2","com3","com4","con","clock$",
  100.                "lpt1","lpt2","lpt3","screen$","pointer$","mouse$");
  101.   
  102.   makedir_drives = dos_mapped_drives();
  103.   
  104.   makedir_new_dirs = list();    /* list of directories created by this script */
  105.   
  106.     {
  107.       while (true) 
  108.     {
  109.       makedir_redo = false;
  110.       
  111.       while (not(empty(makedir_new_dirs))) 
  112.         {            /* clean up */
  113.           makedir_new_dir = first(makedir_new_dirs);
  114.           makedir_new_dirs = rest(makedir_new_dirs);
  115.           remove_directory(makedir_new_dir);
  116.         } [ 'default: continue(); ]
  117.       
  118.           makedir_select_dir_prompt_inst = instantiate(makedir_select_dir_prompt);
  119.           makedir_default_dir_inst = instantiate(makedir_default_dir);
  120.  
  121.       {  
  122.             if (not(makedir_skip_pass))
  123.               signal('UNBOUND_VARIABLE);
  124.       }
  125.           ['UNBOUND_VARIABLE:
  126.             {
  127. /* EEVANS */       
  128.           temp_hack = current_directory(); /* EEVANS */
  129.           change_directory(makedir_old_current_directory); 
  130.  
  131.           makedir_path_to_check = choose_directory_dialog(makedir_select_dir_prompt_inst,
  132.                                                               makedir_default_dir_inst,
  133.                                                               makedir_content,
  134.                                                               makedir_help);
  135.           change_directory(temp_hack);
  136.               continue();
  137.             }
  138.           ]
  139.  
  140.           makedir_skip_pass = FALSE;
  141.  
  142.       pathify(makedir_path_to_check);
  143.  
  144.       /* check for known bad directory structures */
  145.       makedir_bad_trees = makedir_bad_tree_list;
  146.       makedir_bad_tree_messages = makedir_bad_tree_message_list;
  147.       makedir_bad_tree_contents = makedir_bad_tree_content_list;
  148.       makedir_bad_tree_helps = makedir_bad_tree_help_list;
  149.       while (not(empty(makedir_bad_trees)))
  150.         {
  151.           /* Compare the components of the two paths to
  152.          see if makedir_path_to_check is contained within any of
  153.          the elements in makedir_bad_trees */
  154.           path_to_check_list = explode(makedir_path_to_check, "\");
  155.           bad_path_list = explode(first(makedir_bad_trees), "\");
  156.           found_bad = FALSE;
  157.           while (first(bad_path_list) == first(path_to_check_list))
  158.         {
  159.           bad_path_list = rest(bad_path_list);
  160.           path_to_check_list = rest(path_to_check_list);
  161.           if (empty(bad_path_list))
  162.             {
  163.               /* contained path found */
  164.               found_bad = TRUE;
  165.               break();
  166.             }
  167.           else if (empty(path_to_check_list))
  168.             /* path is good */
  169.             break();
  170.         }
  171.  
  172.           if (found_bad)
  173.         {
  174.           makedir_bad_tree_contents_inst = instantiate(first(makedir_bad_tree_contents));
  175.           if (makedir_bad_tree_contents_inst=="")
  176.             information_dialog(instantiate(first(makedir_bad_tree_messages)));
  177.           else
  178.             information_dialog(instantiate(first(makedir_bad_tree_messages)),
  179.                        makedir_bad_tree_contents_inst,
  180.                        instantiate(first(makedir_bad_tree_helps)));
  181.           makedir_redo = TRUE;
  182.           break();
  183.         }
  184.           makedir_bad_trees = rest(makedir_bad_trees);
  185.           makedir_bad_tree_messages = rest(makedir_bad_tree_messages);
  186.           makedir_bad_tree_contents = rest(makedir_bad_tree_contents);
  187.           makedir_bad_tree_helps = rest(makedir_bad_tree_helps);
  188.         }
  189.       if (makedir_redo)
  190.         continue();
  191.       
  192.       /* check for known bad directories */
  193.       makedir_bad_dirs = makedir_bad_dir_list;
  194.       makedir_bad_dir_messages = makedir_bad_dir_message_list;
  195.       makedir_bad_dir_contents = makedir_bad_dir_content_list;
  196.       makedir_bad_dir_helps = makedir_bad_dir_help_list;
  197.       while (not(empty(makedir_bad_dirs)))
  198.         {
  199.           if (makedir_path_to_check==first(makedir_bad_dirs))
  200.         {
  201.           makedir_bad_dir_contents_inst = instantiate(first(makedir_bad_dir_contents));
  202.           if (makedir_bad_dir_contents_inst=="")
  203.             information_dialog(instantiate(first(makedir_bad_dir_messages)));
  204.           else
  205.             information_dialog(instantiate(first(makedir_bad_dir_messages)),
  206.                        makedir_bad_dir_contents_inst,
  207.                        instantiate(first(makedir_bad_dir_helps)));
  208.           makedir_redo = TRUE;
  209.           break();
  210.         }
  211.           makedir_bad_dirs = rest(makedir_bad_dirs);
  212.           makedir_bad_dir_messages = rest(makedir_bad_dir_messages);
  213.           makedir_bad_dir_contents = rest(makedir_bad_dir_contents);
  214.           makedir_bad_dir_helps = rest(makedir_bad_dir_helps);
  215.         }
  216.       if (makedir_redo)
  217.         continue();
  218.       
  219.       if (not(contains(makedir_path_to_check,":"))) 
  220.         {
  221.           information_dialog(instantiate(makedir_specify_drive));
  222.           continue();    /* no : */
  223.         }
  224.       makedir_drive_path = explode(makedir_path_to_check,":",'stringsonly);
  225.       makedir_drive = first(makedir_drive_path); /* find the drive */
  226.       if (not(member(makedir_drives,makedir_drive))) 
  227.         {
  228.           information_dialog(instantiate(makedir_bad_drive));
  229.           continue();            /* bad drive letter */
  230.         }        
  231.       makedir_path = rest(makedir_drive_path);
  232.       if (empty(makedir_path)) 
  233.         {
  234.           information_dialog(instantiate(makedir_no_dir));
  235.           continue();            /* nothing after : */
  236.         }
  237.       makedir_rest_path = rest(makedir_path);
  238.       if (not(empty(makedir_rest_path))) 
  239.         {
  240.           information_dialog(instantiate(makedir_invalid_path));
  241.           continue();            /* extra : */
  242.         }
  243.       makedir_path = first(makedir_path);
  244.       if (first(explode(makedir_path,"\",true,'stringsonly))!="\") 
  245.         {
  246.           information_dialog(instantiate(makedir_absolute_path));
  247.           continue();            /* not absolute path */
  248.         }
  249.       
  250.       {
  251.         makedir_fstype = dos_file_system_type("%makedir_drive%:");
  252.       } ['default: makedir_fstype = 'fat; ]
  253.       /* assume FAT if not disk not accessible - probably floppy */
  254.       
  255.       if ((makedir_fstype!='nfs) || (makedir_fstype!='ntnf)) 
  256.         {
  257.           makedir_bad_chars = list("*","?","<",">","|",",","+","=","[","]",";");
  258.           while (not(empty(makedir_bad_chars))) 
  259.         {                /* check for illegal characters */
  260.           makedir_bad_char = first(makedir_bad_chars);
  261.           makedir_bad_chars = rest(makedir_bad_chars);
  262.           if (contains(makedir_path,makedir_bad_char)) 
  263.             {
  264.               information_dialog(instantiate(makedir_illegal_char));
  265.               makedir_redo = true;
  266.               break();
  267.             } 
  268.         }
  269.           if (makedir_redo) 
  270.         continue();
  271.         }
  272.       
  273.       if (contains(makedir_path,"\\")) 
  274.         {
  275.           information_dialog(instantiate(makedir_invalid_path));
  276.           continue();
  277.         }
  278.       
  279.  
  280.       makedir_names = explode(makedir_path,"\",'stringsonly);
  281.       
  282.       if (empty(makedir_names)) 
  283.         {
  284.           { 
  285.         makedir_root_allowed = makedir_root_allowed; 
  286.           } [ 'unbound_variable: makedir_root_allowed = false; ]
  287.           if (not(makedir_root_allowed)) 
  288.         {
  289.           information_dialog(instantiate(makedir_root_message), 
  290.                      instantiate(makedir_root_content),
  291.                      instantiate(makedir_root_help));
  292.           continue();            /* case of d:\ */
  293.         }
  294.         } 
  295.       else 
  296.         {
  297.           makedir_current_path = "%makedir_drive%:";
  298.           change_directory(makedir_current_path);
  299.           
  300.           /* check for bad names */
  301.           if ((makedir_fstype=='hpfs) || (makedir_fstype=='ntfs)) 
  302.         while (not(empty(makedir_names))) 
  303.           {
  304.             makedir_name = first(makedir_names);
  305.             makedir_names = rest(makedir_names);
  306.             if ((length(makedir_name)>254)) 
  307.               {
  308.             information_dialog(instantiate(makedir_name_too_long));
  309.             makedir_redo = true;        /* too long */
  310.             break();
  311.               }
  312.             if (member(makedir_bad_names,makedir_name)) 
  313.               {
  314.             information_dialog(instantiate(makedir_illegal_name));
  315.             makedir_redo = true;        /* illegal name */
  316.             break();
  317.               }
  318.             makedir_current_path = "%makedir_current_path%\%makedir_name%";
  319.             
  320.             {
  321.               makedir_exists = exists(makedir_current_path);
  322.             } [ 'default: 
  323.                {
  324.              information_dialog(instantiate(makedir_invalid_path));
  325.              makedir_redo = true;        /* can't check existence */
  326.              break();
  327.                } ]
  328.             
  329.             if (makedir_exists) 
  330.               {
  331.             {
  332.               change_directory(makedir_current_path);
  333.             } [ 'default(makedir_signal):
  334.                { 
  335.                  information_dialog(instantiate(makedir_dir_not_accessible));
  336.                  makedir_redo = true;
  337.                  break();
  338.                } ]
  339.               } 
  340.             else 
  341.               {
  342.             {
  343.               make_directory(makedir_current_path);
  344.               if (not(exists(makedir_current_path)))
  345.                 signal('make_directory_failure,"Can't make directory '%makedir_current_path%'.");
  346.               makedir_new_dirs = cons(makedir_current_path,makedir_new_dirs);
  347.             } [ 'default(makedir_signal): 
  348.                { 
  349.                  information_dialog(instantiate(makedir_cant_create_dir));
  350.                  makedir_redo = true; 
  351.                  break(); 
  352.                } ]
  353.               }
  354.           }
  355.           else if ((makedir_fstype=='nfs) || (makedir_fstype=='ntnf)) 
  356.         while (not(empty(makedir_names))) 
  357.           {
  358.             makedir_name = first(makedir_names); /* find last name */
  359.             makedir_names = rest(makedir_names);
  360.             makedir_current_path = "%makedir_current_path%\%makedir_name%";
  361.             {
  362.               makedir_exists = exists(makedir_current_path);
  363.             } [ 'default: 
  364.                {
  365.              information_dialog(instantiate(makedir_invalid_path));
  366.              makedir_redo = true;        /* can't check existence */
  367.              break();
  368.                } ]
  369.             
  370.             if (makedir_exists) 
  371.               {
  372.             {
  373.               change_directory(makedir_current_path);
  374.             } [ 'default(makedir_signal):
  375.                { 
  376.                  information_dialog(instantiate(makedir_dir_not_accessible));
  377.                  makedir_redo = true;
  378.                  break();
  379.                } ]
  380.               } 
  381.             else 
  382.               {
  383.             {
  384.               make_directory(makedir_current_path);
  385.               if (not(exists(makedir_current_path)))
  386.                 signal('make_directory_failure,"Can't make directory '%makedir_current_path%'.");
  387.               makedir_new_dirs = cons(makedir_current_path,makedir_new_dirs);
  388.             } [ 'default(makedir_signal): 
  389.                { 
  390.                  information_dialog(instantiate(makedir_cant_create_dir));
  391.                  makedir_redo = true; 
  392.                  break(); 
  393.                } ]
  394.               }
  395.           }
  396.           else /* FAT */
  397.         while (not(empty(makedir_names))) 
  398.           {
  399.             makedir_name = first(makedir_names);
  400.             makedir_names = rest(makedir_names);
  401.             if (member(makedir_bad_names,makedir_name)) 
  402.               {
  403.             information_dialog(instantiate(makedir_illegal_name));
  404.             makedir_redo = true;        /* illegal name */
  405.             break();
  406.               }
  407.             if (count(makedir_name,".")>1) 
  408.               {
  409.             information_dialog(instantiate(makedir_illegal_name));
  410.             makedir_redo = true;        /* too many .'s */
  411.             break();
  412.               }
  413.             makedir_base_ext = explode(makedir_name,".",'stringsonly);
  414.             makedir_base = first(makedir_base_ext);
  415.             if (length(makedir_base)>8) 
  416.               {
  417.             information_dialog(instantiate(makedir_long_basename));
  418.             makedir_redo = true;        /* basename too long */
  419.             break();
  420.               }      
  421.             makedir__ext = rest(makedir_base_ext);
  422.             if (not(empty(makedir__ext))) 
  423.               {                /* has extension - check it */
  424.             makedir_ext = first(makedir__ext);
  425.             if (length(makedir_ext)>3) 
  426.               {
  427.                 information_dialog(instantiate(makedir_long_extension));
  428.                 makedir_redo = true;        /* extension too long */
  429.                 break();
  430.               }      
  431.               }
  432.             makedir_current_path = "%makedir_current_path%\%makedir_name%";
  433.             {
  434.               makedir_exists = exists(makedir_current_path);
  435.             } [ 'default: 
  436.                {
  437.              information_dialog(instantiate(makedir_invalid_path));
  438.              makedir_redo = true;        /* can't check existence */
  439.              break();
  440.                } ]
  441.             
  442.             if (makedir_exists) 
  443.               {
  444.             {
  445.               change_directory(makedir_current_path);
  446.             } [ 'default(makedir_signal):
  447.                { 
  448.                  information_dialog(instantiate(makedir_dir_not_accessible));
  449.                  makedir_redo = true;
  450.                  break();
  451.                } ]
  452.               } 
  453.             else 
  454.               {
  455.             {
  456.               make_directory(makedir_current_path);
  457.               if (not(exists(makedir_current_path)))
  458.                 signal('make_directory_failure,"Can't make directory '%makedir_current_path%'.");
  459.               makedir_new_dirs = cons(makedir_current_path,makedir_new_dirs);
  460.             } [ 'default(makedir_signal): 
  461.                { 
  462.                  information_dialog(instantiate(makedir_cant_create_dir));
  463.                  makedir_redo = true; 
  464.                  break(); 
  465.                } ]
  466.               }
  467.           }
  468.  
  469.               /* If Shared mode, must be Sharable directory */
  470.               if (installation_mode == 'shared)
  471.                 if (not(member(list('remote,'netware),makedir_fstype)))
  472.                 {
  473.           /* EEVANS so it finds response file! */
  474.               temp_hack = current_directory(); /* EEVANS */
  475.               change_directory(makedir_old_current_directory); 
  476.  
  477.                   makedir_redo = not(yesno_dialog(
  478.                                       instantiate(makedir_not_shared),
  479.                                       makedir_not_shared_default,
  480.                                       instantiate(makedir_not_shared_content),
  481.                                       instantiate(makedir_not_shared_help)));
  482.                  change_directory(temp_hack);
  483.                }
  484.           if (makedir_redo)
  485.         continue();
  486.           
  487.           /* reject if last name contains tabs or final white space */
  488.           if (implode(explode(makedir_name,'stringsonly))!=makedir_name) 
  489.         {
  490.           information_dialog(instantiate(makedir_has_white_space));
  491.           continue();
  492.         }
  493.         }
  494.       change_directory(makedir_old_current_directory);
  495.       return(makedir_path_to_check);
  496.     }
  497.     } [ 'default(uncaught_signal, uncaught_signal_message): 
  498.        {
  499.      while (not(empty(makedir_new_dirs))) 
  500.        {
  501.          makedir_new_dir = first(makedir_new_dirs);
  502.          makedir_new_dirs = rest(makedir_new_dirs);
  503.          remove_directory(makedir_new_dir);
  504.        } [ 'default: continue(); ]
  505.      change_directory(makedir_old_current_directory);
  506.      signal(uncaught_signal, uncaught_signal_message);
  507.        } ]
  508. }
  509.